<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org"
	xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<meta charset="utf-8">
<head th:include="include :: header"></head>
<body class="gray-bg">
	
	<div class="container-div">
		<div class="row">
			<div class="col-sm-12 search-collapse">
				<form id="detail-form">
					<input name="planCfgItemPlanId" id="planCfgItemPlanId" type="hidden"  th:value="${planConfig.planCfgId}" />
					<div class="select-list">
						<ul>
						    <li>
								计划名称：<select id="plan" name="plan" onchange="planChange()">
											<option th:each="plan:${planConfigList}" th:value="${plan.planCfgId}" th:text="${plan.planCfgName}" th:field="*{planConfig.planCfgId}"></option>
										</select>
							</li>
							<li>
								项目名称：<input type="text" name="planCfgItemName"/>
							</li>
							<li>
								项目状态：<select name="planCfgItemType" th:with="type=${@dict.getType('plan_item_type')}">
											<option value="">所有</option>
											<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
										</select>
							</li>
							<li>
								<a class="btn btn-success btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
							    <a class="btn btn-success btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
							</li>
						</ul>
					</div>
				</form>
			</div>
			
	       <div class="btn-group-sm hidden-xs" id="toolbar" role="group">
			   <a class="btn btn-success" th:onclick="'javascript:$.operate.add(\''+${planConfig.planCfgId}+'\')'" shiro:hasPermission="plan:config:add">
				   <i class="fa fa-plus"></i> 新增
			   </a>
			   <a class="btn btn-success btn-edit disabled" onclick="$.operate.edit()" shiro:hasPermission="plan:config:edit">
				   <i class="fa fa-edit"></i> 修改
			   </a>
			   <a class="btn btn-danger btn-del disabled" onclick="$.operate.removeAll()" shiro:hasPermission="plan:config:remove">
				   <i class="fa fa-remove"></i> 删除
			   </a>
		        <!--<a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="system:dict:export">-->
		            <!--<i class="fa fa-download"></i> 导出-->
		        <!--</a>-->
	        </div>
	        
	        <div class="col-sm-12 select-table table-striped">
			    <table id="bootstrap-table" data-mobile-responsive="true"></table>
			</div>
		</div>
	</div>
	<div th:include="include :: footer"></div>
	<script th:src="@{/ajax/libs/select/select2.js}"></script>
	<script th:inline="javascript">
		var editFlag = [[${@permission.hasPermi('plan:config:edit')}]];
		var removeFlag = [[${@permission.hasPermi('plan:config:remove')}]];
		var datas = [[${@dict.getType('plan_item_type')}]];
		var prefix = ctx + "plan/config/detail";

		$(function() {
			var options = {
				url: prefix + "/list",
				createUrl: prefix + "/add/{id}",
				updateUrl: prefix + "/edit/{id}",
				removeUrl: prefix + "/remove",
				exportUrl: prefix + "/export",
				validateUrl: prefix + "/checkPublish",
				queryParams: queryParams,
				sortName: "createTime",
		        sortOrder: "desc",
				modalName: "计划子项目",
				search: false,
		        showExport: false,
				columns: [{
						checkbox: true
					},
					{
						field: 'planCfgItemRecordid',
						title: '记录ID'
					},
				  	{
						field: 'planCfgItemPlanId',
						title: '计划ID'
					},
					{
						field: 'planCfgItemId',
						title: '计划子项目ID'
					},
					{
						field: 'planCfgItemName',
						title: '计划子项目名称'
					},
					{
						field: 'planCfgItemType',
						title: '子项目类型',
						align: 'center',
						formatter: function(value, row, index) {
							return $.table.selectDictLabel(datas, value);
						}
					},
					{
						field: 'planCfgItemWeight',
						title: '权重'
					},
					{
						field: 'planCfgItemUpdateTime',
						title: '更新时间'
					},
					{
						title: '操作',
						align: 'center',
						formatter: function(value, row, index) {
							var actions = [];
							actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="#" onclick="$.operate.edit(\'' + row.planCfgItemRecordid + '\',' + row.planCfgItemPlanId + ')"><i class="fa fa-edit"></i>编辑</a> ');
							actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="#" onclick="$.operate.remove(\'' + row.planCfgItemRecordid + '\')"><i class="fa fa-remove"></i>删除</a>');
							return actions.join('');
						}
					}]
				};
			$.table.init(options);
		});

		function planChange(){
			$("#planCfgItemPlanId").val($("#plan option:selected").val());
		}
		
		function queryParams(params) {
			return {
				planCfgItemPlanId:       $("#plan option:selected").val(),
				pageSize:       params.limit,
    			pageNum:        params.offset / params.limit + 1,
    			searchValue:    params.search,
    			orderByColumn:  params.sort,
    			isAsc:          params.order
			};
		}
	</script>
</body>
</html>